home *** CD-ROM | disk | FTP | other *** search
/ 3D World 113 / 3DW_113.iso / pc / Menu / Scenes / home.dir / Internal_50_Hypertext - General.ls < prev    next >
Encoding:
Text File  |  2008-09-12  |  4.5 KB  |  103 lines

  1. property spriteNum, pHyperStyle, getPDLError
  2.  
  3. on getBehaviorDescription me
  4.   return "GENERAL PURPOSE HYPERLINK BEHAVIOR" & RETURN & RETURN & "This is a hyperlink behavior that operates on hyperlink data. " & "It will interpret the DATA string depending on what is at the beginning of the string." & RETURN & RETURN & "PARAMETERS:" & RETURN & "* Use hyperlink styles - Check if you want to use the built in hyperlink style." & RETURN & RETURN & "USEAGE:" & RETURN & "* URL schemes. " & "The following URL schemes are supported by this behavior:" & RETURN & "            http://   https://   mailto:   ftp://" & RETURN & "When the data string assigned to a hyperlink starts with one of these schemes, clicking it will perform a gotoNetPage on the URL" & RETURN & "* RELATIVE filepaths. " & "Relative file paths are supported. " & "You may start the hyperlink data string with the following:" & RETURN & "            ./   ../   @" & RETURN & "When the data string assigned to a hyperlink starts with one of these strings, clicking it will perform a gotoNetPage on the filepath." & RETURN & "NOTE: the \" & QUOTE & " @ \" & QUOTE & " symbol works in any environment. " & "The Unix style path delimiters \" & QUOTE & " ./ \" & QUOTE & " and \" & QUOTE & " ../ \" & QUOTE & " only work from Shockwave." & RETURN & "* LINGO. " & "Any string starting with \" & QUOTE & "lingo:\" & QUOTE & " will be treated as a Lingo command and will be executed with the Lingo \" & QUOTE & "do\" & QUOTE & " command. " & "If your Lingo command requires a quoted string, use single quotes. " & "The single quotes will be converted into double quotes before the command is execuited." & RETURN & RETURN & "For more information, open this script in the script editor and read the comments at the top."
  5. end
  6.  
  7. on getBehaviorTooltip me
  8.   return "Use this behavior on text members containing hyperlink data. " & "It will process URL's and Lingo commands."
  9. end
  10.  
  11. on beginSprite me
  12.   theMember = sprite(spriteNum).member
  13.   if pHyperStyle = 1 then
  14.     theMember.useHypertextStyles = 1
  15.   else
  16.     theMember.useHypertextStyles = 0
  17.   end if
  18.   repeat with i = 1 to theMember.hyperlinks.count
  19.     theLink = theMember.hyperlinks[i]
  20.     theMember.char[theLink[1]].hyperlinkState = #normal
  21.   end repeat
  22. end
  23.  
  24. on hyperlinkClicked me, data, range
  25.   if data starts "http://" then
  26.     gotoNetPage(data)
  27.   else
  28.     if data starts "https://" then
  29.       gotoNetPage(data)
  30.     else
  31.       if data starts "ftp://" then
  32.         gotoNetPage(data)
  33.       else
  34.         if data starts "@" then
  35.           gotoNetPage(data)
  36.         else
  37.           if data starts "mailto:" then
  38.             gotoNetPage(data)
  39.           else
  40.             if data starts "./" then
  41.               if the runMode = "plugin" then
  42.                 gotoNetPage(data)
  43.               else
  44.                 beep()
  45.                 alert("This relative filepath only works from Shockwave.")
  46.               end if
  47.             else
  48.               if data starts "../" then
  49.                 if the runMode = "plugin" then
  50.                   gotoNetPage(data)
  51.                 else
  52.                   beep()
  53.                   alert("This relative filepath only works from Shockwave.")
  54.                 end if
  55.               else
  56.                 if data starts "lingo:" then
  57.                   theOffset = offset(":", data)
  58.                   theCommand = data.char[theOffset + 1..data.char.count]
  59.                   repeat while offset("'", theCommand)
  60.                     put QUOTE into theCommand.char[offset("'", theCommand)]
  61.                   end repeat
  62.                   do(theCommand)
  63.                 end if
  64.               end if
  65.             end if
  66.           end if
  67.         end if
  68.       end if
  69.     end if
  70.   end if
  71.   theMember = sprite(spriteNum).member
  72.   theMember.char[range[1]].hyperlinkState = #Visited
  73. end
  74.  
  75. on isOKToAttach me, aSpriteType, aSpriteNum
  76.   case aSpriteType of
  77.     #graphic:
  78.       return sprite(aSpriteNum).member.type = #text
  79.     #script:
  80.       return 0
  81.   end case
  82. end
  83.  
  84. on getPropertyDescriptionList me
  85.   if the currentSpriteNum <> 0 then
  86.     theMember = the member of sprite the currentSpriteNum
  87.     links = []
  88.     links = theMember.hyperlinks
  89.     linkCount = links.count
  90.     repeat with i = 1 to linkCount
  91.       theLink = links[i]
  92.       theData = theMember.char[theLink[1]..theLink[2]].hyperlink
  93.       theData = theMember.char[theLink[1]].hyperlink
  94.       repeat while offset(QUOTE, theData)
  95.         put "'" into theData.char[offset(QUOTE, theData)]
  96.       end repeat
  97.     end repeat
  98.     p_list = [:]
  99.     addProp(p_list, #pHyperStyle, [#format: #boolean, #default: 1, #comment: "Use hyperlink styles?"])
  100.     return p_list
  101.   end if
  102. end
  103.